using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class medicalMap : EntityTypeConfiguration<medical>
    {
        public medicalMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Cust_id)
                .IsRequired()
                .HasMaxLength(6);

            // Table & Column Mappings
            this.ToTable("medical");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Cust_id).HasColumnName("Cust_id");
            this.Property(t => t.disease_id).HasColumnName("disease_id");
            this.Property(t => t.Note).HasColumnName("Note");

            // Relationships
            this.HasRequired(t => t.Cust)
                .WithMany(t => t.medicals)
                .HasForeignKey(d => d.Cust_id);

        }
    }
}
